package com.linkage.yninterface.process;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.linkage.yninterface.util.frameException;
import com.linkage.yninterface.util.config.serverconfig.loginInfo;

/**
 * 
 * @author weib
 * @version 1.0
 */
public class writeOperationLog {
	private static final Logger log = LoggerFactory
			.getLogger(writeOperationLog.class);

	private static final String REQUEST = "REQ:";
	private static final String RESPONSE = "RSP:";

	public static void write(String clientIp, frameException fe,
			String strLogin, String userData, String threadName) {
		StringBuffer message = new StringBuffer();
		message.append(threadName + "; frameException: " + " login " + strLogin
				+ " ...START\n");
		message.append(REQUEST + clientIp + ":" + userData + "\n");
		message.append(RESPONSE + fe.getResultCode() + "- " + fe.getReaultDes()
				+ "...END");

		log.info(message.toString());
	}

	public static void write(String clientIp, processPara pp, processResult pr,
			String threadName) {
		StringBuffer message = new StringBuffer();
		loginInfo li = pp.getLogininfo();
		message.append(threadName + "; login " + li.getLoginName() + " "
				+ li.getLoginPWD() + " " + li.getLoginArea() + " "
				+ li.getLoginIP() + " ...START\n");
		message.append(REQUEST + clientIp + ":" + pp.getOperationType() + "|||"
				+ pp.getDealType() + "|||" + pp.getSourceString() + "\n");
		message.append(RESPONSE + pr.getResultCode() + "- " + pr.getResultDes()
				+ "...END");

		log.info(message.toString());
	}
}
